<!DOCTYPE html>
<html lang="{{ .Site.Language }}">
  <head>
    <title>
      {{- block "title" . -}}
      {{ if .IsPage }}
        {{ .Title }} - {{ .Site.Title }}
      {{ else}}
        {{ .Site.Title}}{{ end }}
      {{- end -}}
    </title>
    {{ partial "head.html" . }}
  </head>
  {{- $.Scratch.Add "bodyClass" slice }}
  {{- $config := .Site.Params.config }}
  {{- if $config.layout }}
    {{- $.Scratch.Add "bodyClass" $config.layout }}
  {{- else }}
    {{- $.Scratch.Add "bodyClass" "main-center" }}
  {{- end }}
  {{- with $config.skin }}
    {{- $.Scratch.Add "bodyClass" . }}
  {{- end}}
  {{- if eq .Site.Params.sidebar "none"}} 
    {{- $.Scratch.Add "bodyClass" "no-sidebar" }}
  {{- end }}

  <!-- gen regular pages by mainSections -->
  <!-- if exists, delete it -->
  {{- if ($.Scratch.Get "pages") }}
    {{- $.Scratch.Delete "pages"}}
  {{- end}}
  {{- if and (.Site.Params.mainSections) (ge (len .Site.Params.mainSections) 0) }}
  {{- $.Scratch.Add "pages" (where .Site.RegularPages "Type" "in" .Site.Params.mainSections)  }}
  {{- else }}
  {{- $.Scratch.Add "pages" (.Site.RegularPages) }}
  {{- end }}

  <body class="{{- delimit ( $.Scratch.Get "bodyClass" ) " " }}" itemscope itemtype="http://schema.org/WebPage">
    {{- partial "header.html" .}}
    {{- if and (.Site.Params.sidebar) (or (ne .Params.sidebar "none") (ne .Params.sidebar "custom"))}}
        {{- partial "sidebar.html" . }}
    {{end}}
    {{ block "content" . }}{{ end }}
    {{- partial "footer.html" . }}
    {{- partial "script.html" . }}
  </body>
</html>
